#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<string.h>
int main()
{
    umask(0);
    close(1);
    int fd=open("myfile.txt",O_CREAT|O_WRONLY|O_TRUNC,0666);
    if(fd<0)
    {
        perror("open");
        return -1;
    }
    fprintf(stdout,"Open file success!,fd:%d\n",fd);
    fflush(stdout);
    close(fd);
    return 0;
}
